<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.hzqy.commons.utils.SystemConfigUtils"%>
<%@page import="com.hzqy.web.login.SessionKey"%>
<%@ page import="com.hzqy.web.vo.PmsOrgVo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<%@include file="/commons/commons.jsp" %>
	<%@include file="/commons/common_css_js.jsp" %>
	<%@include file="/commons/commons_data.jsp" %>
	<%@include file="/commons/turnPage.jsp" %>
<title>全屏播放跳转页面</title>
<!-- 
	播放调用方式
	industry/play/play_transfer.jsp?contentid=&contentType=
	type:1 :contentid ;2:频道号；3：igmp地址；4：播放code;5:rtsp地址；6：内容组（1,2,3）
	直播类型频道号放在f_cc_obligate1中，中兴华为使用“，”分隔
	
	
	页面需要实现功
		1.大网接口与中兴接口获取播放url中转页面
		2.
	调用小窗口播放是需要父级页面添加调用iframe包含页面机顶盒响应事件的方法
	
	例：
	if($("mv_box")){
		if(window.mv_box){
			window.mv_box.checkMvKey(keycode);
		}else if($("mv_box").contentWindow){
			$("mv_box").contentWindow.checkMvKey(keycode);
		}
		//document.getElementById("mv_box").contentWindow.checkMvKey(keycode);
	}	
 -->
<%
String contentid=request.getParameter("contentid");//第一次传入id组或单个内容id	必须
String contentType=request.getParameter("contentType");//第一次传入id组或单个内容id	必须
String f_ssc_id=request.getParameter("f_ssc_id");//剧集ID_连续剧单集id用于标记播放起始位置
String jumpType=request.getParameter("jumpType");//跳转类型_暂时为内部参数
String backtype=request.getParameter("backtype");//返回类型 2为epg返回
String disableEvent=request.getParameter("disableEvent");//事件禁用 3禁用按键事件
String categoryId=request.getParameter("categoryId");
PmsOrgVo orgVo=(PmsOrgVo)session.getAttribute(SessionKey.SESSION_USER_FOR_ORG_INFO);
String orgId="0";
if(orgVo!=null){
	orgId=String.valueOf(orgVo.getF_po_id());
}
if(categoryId==null){
	categoryId="0";
}
String index=request.getParameter("index");
if(index==null){
	index="0";
}
String partner=current_partner;//平台类型
String preType=request.getParameter("preType");//_内部参数
String playEnd=request.getParameter("playEnd");//1 循环播放	2 直接返回
if(playEnd==null){
	playEnd="2";
}
if(contentType==null){
	contentType="0";
}
String preUrl="";
TurnPage tp = new TurnPage(request,session);
if(preType==null){//此参数为内部转跳时传递，未带时认为初次进入记录上级页面
	preType="0";
	HashMap<String,String> tpHash = tp.isPreUrl("focus");//记录上级页面
	preUrl = tp.getValue(tpHash,"url","","");
}else{
	HashMap<String,String> tpHash = tp.getPreUrl();
	preUrl = tp.getValue(tpHash,"url","","");
	contentid=tp.getValue(tpHash,"contentid","","");
	if(contentid==null){
		contentid="0";
	}
}
%>
</head>
<body bgcolor="transparent">
 <!-- <div id="ss" style="position:absolute;left:100px;top:100px; color:red;font-size: 50px;width:900px;word-wrap: break-word;">加载中...</div>
<a href="#" onclick="location.reload()">ssfsdfe</a>  -->
<script>
	var contentid="<%=contentid%>";
	var partner="<%=partner%>";
	var relativePathPrefix="../../";
	var preType="<%=preType%>";
	var f_ssc_id="<%=f_ssc_id==null?"":f_ssc_id%>";
	var jumpType="<%=jumpType==null?"0":jumpType%>";
	var contentType="<%=contentType%>";
	var playEnd="<%=playEnd%>";
	var mediaStr="";
	var mediaUrl="";
	var backUrl="<%=preUrl%>";
	var index=parseInt("<%=index%>");
	var contentList="";
	var channelId="1";
	var contentJson="";
	window.onload=function(){
		//播放返回地址拼接
		mediaUrl="<%=cloudTwoPlaneUrl%>industry/play/play_media.jsp?disableEvent=<%=disableEvent%>&playEnd="+playEnd+"&categoryId=<%=categoryId%>&backtype=<%=backtype%>&contentType="+contentType+"&index="+index;
		if(contentType==0||contentType==3||contentType==5){//其他类型
			commontools.contentOtherJump();
		}else{
			if(contentType==2){//频道号
				commontools.contentLiveJump(1);
			}else if(contentType==4){//播放code
				mediaStr=contentid;
				mediaUrl=mediaUrl+"&mediaCode="+mediaStr;
				contentid=encodeURIComponent(contentid);
				commontools.partnerVodJump();
			}else if(contentType==6){//多视频轮播，注意下一页面需要contentid列表判断播放长度
				mediaUrl+="&contentid="+contentid;
				contentList=contentid.split(",");
				contentid=contentList[index];
				preInfo();
			}else{//单视频播放
				mediaUrl+="&contentid="+contentid;
				preInfo();
			}
		}
	}
	function preInfo(){
		mediaStr=contentid;
		getContent(relativePathPrefix,contentid,content.requestContentData);
	}
	var content = {
			requestContentData : function(__xmlhttp) {
				try{
					contentJson = Josncheck(__xmlhttp.responseText);
					commontools.contentReviewType(contentJson);
				}catch(e){
					//back();
					//document.getElementById("ss").innerHTML=e; 
				}
			}
	};
	var commontools={
			partnerVodJump:function(){
				switch(partner){
					case 'HW':
						getHWMediaStr();
						break;
					case 'ZTE':
						getZTEMediaStr();
						break;
					default : 
						getHWMediaStr();
						break;
				}
			},
			contentLiveJump:function(flag_){
				if(flag_==1){
					channelId=contentid;
				}else if(flag_==2){//取内容obligate1
					channelId=contentJson.f_cc_obligate1;
				}
				if(reviewStrContain(channelId,",")){
					var xxx=channelId.split(",");
					if(partner=="HW"){
						mediaStr=xxx[0];
					}else{
						mediaStr=xxx[1];
					}
				}else{
					mediaStr=channelId;
				}
				goLivePlay();
			},
			contentOtherJump:function(){
				if(reviewStrContain(contentid,"rtsp://")){
					mediaStr=contentid;
					mediaStr=encodeURIComponent(mediaStr);
					goMoviePlay();
				}else if(reviewStrContain(contentid,"igmp://")){
					mediaStr=contentid;
					mediaStr=encodeURIComponent(mediaStr);
					goLiveIgmp();
				}else{
					preInfo();
				}
			},
			contentReviewType:function(){
				switch(contentJson.f_cc_type){
					case 1://电视剧
						break;
					case 2://电影
						mediaStr=contentJson.f_cc_code;
						mediaUrl=mediaUrl+"&mediaCode="+mediaStr;
						if(reviewStrContain(mediaStr,"rtsp://")){
							mediaStr=encodeURIComponent(mediaStr);
							goMoviePlay();
						}else{
							commontools.partnerVodJump();
						}
						break;
					case 3://直播
							if(reviewStrContain(contentJson.f_cc_obligate1,"igmp://")){
								mediaStr=contentJson.f_cc_obligate1;
								mediaStr=encodeURIComponent(mediaStr);
								goLiveIgmp();
							}else{
								commontools.contentLiveJump(2);
							}
						break;
					default : 
						//back();
						break;
				}
			}
	}
	function getZTEMediaStr(){//获取中兴播放mediaStr
		var epgdomain = Authentication.CTCGetConfig("EPGDomain");
		var last = epgdomain.lastIndexOf("/");
		var host = epgdomain.substr(0,last);
		mediaUrl=encodeURIComponent(mediaUrl);
		var requrl = host + "/MediaService/SmallScreen?ContentID="+mediaStr+"&ReturnURL="+mediaUrl+"&ifameFlag=1";
		window.location.href = requrl;
	}
	function goMoviePlay(){//存在播放地址直接转跳播放
		window.location.href=mediaUrl+"&mediaUrl="+mediaStr+"&partner=HW";
	}
	function goLiveIgmp(){
		try{//直播流播放前，需要查询是否已开权限
			var url=relativePathPrefix+'externalLink/selectWLContentAvaliable.do?f_wlc_path=' + mediaStr + '&f_wlc_orgid=<%=orgId%>&sysConfigKey=control_link_ab';
			var ajax = new AJAX_OBJ(url, function(__xmlhttp){
				if(__xmlhttp.responseText) {
					var json = Josncheck(__xmlhttp.responseText);
					if(json && json.f_wlc_path) {
						window.location.href="<%=cloudTwoPlaneUrl%>industry/play/live_big.jsp?contentid="+contentid+"&playUrl="+mediaStr;
					}
				}
			});
			ajax.requestData();
		}catch(e){
		}
	}
	function goLivePlay(){//前往播放直播内容
		window.location.href="<%=cloudTwoPlaneUrl%>industry/play/live_big.jsp?contentid="+contentid+"&playUrl="+mediaStr;
	}
	function getHWMediaStr(){//获取华为播放resp地址
		mediaUrl=encodeURIComponent(mediaUrl);
		var vas_info = "<vas_action>play_code</vas_action><mediacode>"+mediaStr+"</mediacode><vas_back_url>"+mediaUrl+"</vas_back_url>";
		var url="<%=play_code_give_url%>?vas_info="+encodeURIComponent(vas_info);
		window.location.href = url;
	}
	function reviewStrContain(str,str1){
		if(str.indexOf(str1)>=0){
			return true;
		}else{
			return false;
		}
	}
	function back(){
		window.location.href=backUrl;
	}
	//遥控器按键控制
	function grabEvent(evt) {
		evt = evt?evt:window.event;
		var keycode = evt.keyCode;
		var flag=true;
		if(keycode == 8){
			back();
		}
	}
	document.onkeypress=grabEvent;
	document.onirkeypress=grabEvent;
</script>
</body>
</html>